//
//  TabItemView.swift
//  WWDCLearn
//
//  Created by mac on 2021/6/30.
//

import Cocoa


extension NSStackView {
    var computedContentSize: CGSize {
        func horizontal(

        ) -> CGSize {
            let height = arrangedSubviews.map( { $0.bounds.height}).max() ?? CGFloat(0)
            let width = arrangedSubviews.reduce(CGFloat(0), {$0 + $1.intrinsicContentSize.width + spacing})
            return CGSize(width: width - spacing, height: height)
        }

        switch orientation {
        case .horizontal:
               return horizontal()
        case .vertical:
            let width = arrangedSubviews.map({ $0.bounds.width}).max() ?? CGFloat(0)
            let height = arrangedSubviews.reduce(CGFloat(0), {$0 + $1.intrinsicContentSize.height + spacing })
            return CGSize(width: width, height: height - spacing)
        }
    }
}


final class TabItemView:NSView {
  @objc  var target:Any?
    @objc   var action:Selector?
    var controllerIdentifier:String = ""
    
    lazy var titleLabel: NSTextField = {
        let l = NSTextField(labelWithString: "")
        l.font =  .systemFont(ofSize: 14)
        l.textColor = .toolbarTint
        l.cell?.backgroundStyle = .dark
        return l
    }()
    
    var title: String? {
        didSet{
//            titleLal
        }
    }
    
}
